function showUserDetails(){
	
	var userName=document.getElementById("userName").value;
	if(userName.length==0){
		document.getElementById('message').innerHTML = "<h4><span style='color:red'>Please enter username</span></h4>";
		return
	}
	$.ajax({
		url : 'fetchUserDetails',
		type:"POST",
		data : ({
			userName : userName
		}),
		success : function(data) {
			$('#displayUsers').html(data);

		}
	});
}


function validateForm()
{
  
		var x=document.forms["form"]["username"].value;
		if (x==null || x=="")
		  {
			document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Please enter userName</span></h4>";
		  return false;
		  }
		var x=document.forms["form"]["password"].value;
		if (x==null || x=="")
		  {
			document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Password field is mandatory</span></h4>";
		  return false;
		  }
		var x=document.forms["form"]["firstName"].value;
		if (x==null || x=="")
		  {
			document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>FirstName field is mandatory</span></h4>";
		  return false;
		  }
		var x=document.forms["form"]["lastName"].value;
		if (x==null || x=="")
		  {
			document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>LastName field is mandatory</span></h4>";
		  return false;
		  }
		
		var x=document.forms["form"]["email"].value;
		if (x==null || x=="")
		  {
			document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>please enter a valid email</span></h4>";
		  return false;
		  }
		var x=document.forms["form"]["email"].value;
		var atpos=x.indexOf("@");
		var dotpos=x.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
		  {
		  alert("Not a valid e-mail address");
		  return false;
		  }
		var x=document.forms["form"]["role"].value;
		if (x==null || x=="")
		  {
			document.getElementById('errorMsg').innerHTML = "<h4><span style='color:red'>Please select a role </span></h4>";
		  return false;
		  }
		return true;
  }


var s = "update";
function deleteForm()
{
	s="delete";
	return false;
	}
function doValidateForm()
{
	if(s!="delete")

{
	var firstName=document.getElementById("firstname").value;
	var lastName=document.getElementById("lastname").value;
	var email=document.getElementById("email").value;
	var role=document.getElementById("role").value;
	 if(firstName.length==0 || firstName=="")
	{
		
		document.getElementById('errormsg').innerHTML="<font color='red' size='4'>FirstName is manadatory</font>";
		return false;
	}
	else if(lastName.length=0 || lastName=="")
		{
		document.getElementById('errormsg').innerHTML="<font color='red' size='4'>LastName is manadatory</font>";
			return false;
		} 
	else if(email.length==0 || email=="")
		{
		document.getElementById('errormsg').innerHTML="<font color='red' size='4'>Email is manadatory</font>";
			return false;
		}
	else if(email.length>0)
	{
		var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		if(!re.test(email))
		{
			document.getElementById('errormsg').innerHTML="<font color='red' size='4'>Not a valid Email</font>";
			return false;
		}	
		
	}
	if(role.length=="" || role=="")
	{
		document.getElementById('errormsg').innerHTML="<font color='red' size='4'> Please select the role </font>";
			return false;
	}
	return true;
}
	else{
	return true;
}
}
